package com.pg.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pg.entity.ycl.EipArcContact;
import com.pg.mapper.EipArcContactMapper;
import com.pg.service.EipArcContactService;
import com.pg.utils.Jpg2Base64Util;
import com.pg.utils.UploadFileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;


/**
 * <p>
 * 断路器弧触头 服务实现类
 * </p>
 *
 * @author likl
 * @since 2020-07-06
 */
@Service
@DS("proxyDs")
@Primary
public class EipArcContactServiceImpl extends ServiceImpl<EipArcContactMapper, EipArcContact> implements EipArcContactService {

    @Autowired
    private EipArcContactMapper eipArcContactMapper;

    @Override
    public void saveOne(EipArcContact arcContact) {
        if (arcContact.getCheckResult() != null) {
            String filePath = "/root/" + arcContact.getCheckResult();
            arcContact.setCheckResultObj(UploadFileUtils.uploadFiles(Jpg2Base64Util.Jpg2Base64(filePath)));
            eipArcContactMapper.insert(arcContact);
        } else {
            arcContact.setCheckResultObj(null);
            eipArcContactMapper.insert(arcContact);
        }
    }
}
